package xing.service.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xing.infrastructure.data.CallResult;

/********************************
 * 文 件 名 :ReleaseUrlController.java
 * 创 建 人：陈天龙
 * 日    期：2017/9/8
 * 描   述：地址发布控制层
 * 版 本 号：v1.0.0
 ********************************/
@Api(value = "地址发布",description = "地址发布相关的RESTful Api")
@RestController
@RequestMapping("/release")
public class ReleaseUrlController {

    private @Value("${web.main-url}") String mainUrl;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 描    述：获取发布地址
     * 创 建 人：陈天龙
     * 日    期：2017/9/8
     * @param corpId
     * @return CallResult
     */
    @ApiOperation(value="获取发布地址", notes="获取发布地址",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParam(name = "corpId", value = "企业号", required = true, dataType = "String",paramType = "path")
    @GetMapping("/{corpId}")
    public CallResult getUrl(@PathVariable("corpId")String corpId){
        logger.info("进入获取企业"+corpId+"发布地址的控制层");
        String url = mainUrl+"/index.html?appid=4099&corpid="+corpId+"&v=dist100#";
        return CallResult.ok(url);
    }
}
